package com.tywj.panda.pay.api

import com.tywj.panda.customer.common.api.CommonApi
import com.tywj.panda.customer.common.tool.HttpTool
import com.tywj.lib.net.retrofit.request.GetRequest
import com.tywj.lib.net.retrofit.request.PostRequest


/**
 * <pre>
 *     author : June Yang
 *     time   : 2018/12/25
 *     desc   : 支付接口
 *     version: 1.0
 * </pre>
 */
object PayApi {


    ///v1/pay/prepayment/ 生成预付款信息 POST /ticket/order/pre
    private var PRE_PAYMENT = CommonApi.API_TICKET_URL + "ticket/order/pre"


    // 订单详情 GET /ticket/orderinfo/search/order/detail  服务器端需要优化成GET
    private var ORDER_DETAIL = CommonApi.API_TICKET_URL + "ticket/orderinfo/search/order/detail/"

    /**
     * 生成预付款信息
     * @param app_type (string, optional): 应用类型（Apple: IOS_CC, Android: ANDROID_CC MP:WECHAT_MP_CC）
     * @param orderNo 订单号
     * @param payType 支付方式, （C003 微信, C004 支付宝 C009 小程序）
     * @param money  合計金額(分)
     */
    fun prepayment(appType: String = "ANDROID_CC", orderNo: String, payType: String, money: Int): PostRequest {
        return HttpTool.post(PRE_PAYMENT)
            .param("app_type", appType)
            .param("money", money)
            .param("order_no", orderNo)
            .param("pay_type", payType)
    }

    fun getOrderDetail(orderId: String): GetRequest {
        return HttpTool.get(ORDER_DETAIL).param("order_serial_no", orderId)
    }
}